package com.ruoyi.dispatch.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.dispatch.domain.LeaderDutyReport;
import com.ruoyi.dispatch.enums.LeaderDutyReportCol;
import com.ruoyi.dispatch.mapper.LeaderDutyReportMapper;
import com.ruoyi.dispatch.service.ILeaderDutyReportService;
import org.apache.commons.compress.utils.Lists;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 矿领导带班Service业务层处理
 * 
 * @author maxing
 * @date 2025-04-09
 */
@Service
public class LeaderDutyReportServiceImpl implements ILeaderDutyReportService 
{
    @Autowired
    private LeaderDutyReportMapper leaderDutyReportMapper;

    /**
     * 查询矿领导带班
     * 
     * @param dutyId 矿领导带班主键
     * @return 矿领导带班
     */
    @Override
    public LeaderDutyReport selectLeaderDutyReportByDutyId(Long dutyId)
    {
        return leaderDutyReportMapper.selectLeaderDutyReportByDutyId(dutyId);
    }

    /**
     * 查询矿领导带班列表
     * 
     * @param leaderDutyReport 矿领导带班
     * @return 矿领导带班
     */
    @Override
    public List<LeaderDutyReport> selectLeaderDutyReportList(LeaderDutyReport leaderDutyReport)
    {
        return leaderDutyReportMapper.selectLeaderDutyReportList(leaderDutyReport);
    }

    /**
     * 新增矿领导带班
     * 
     * @param leaderDutyReport 矿领导带班
     * @return 结果
     */
    @Override
    public int insertLeaderDutyReport(LeaderDutyReport leaderDutyReport)
    {
        leaderDutyReport.setCreateTime(DateUtils.getNowDate());
        return leaderDutyReportMapper.insertLeaderDutyReport(leaderDutyReport);
    }

    /**
     * 修改矿领导带班
     * 
     * @param leaderDutyReport 矿领导带班
     * @return 结果
     */
    @Override
    public int updateLeaderDutyReport(LeaderDutyReport leaderDutyReport)
    {
        leaderDutyReport.setUpdateTime(DateUtils.getNowDate());
        return leaderDutyReportMapper.updateLeaderDutyReport(leaderDutyReport);
    }

    /**
     * 批量删除矿领导带班
     * 
     * @param dutyIds 需要删除的矿领导带班主键
     * @return 结果
     */
    @Override
    public int deleteLeaderDutyReportByDutyIds(Long[] dutyIds)
    {
        return leaderDutyReportMapper.deleteLeaderDutyReportByDutyIds(dutyIds);
    }

    /**
     * 删除矿领导带班信息
     * 
     * @param dutyId 矿领导带班主键
     * @return 结果
     */
    @Override
    public int deleteLeaderDutyReportByDutyId(Long dutyId)
    {
        return leaderDutyReportMapper.deleteLeaderDutyReportByDutyId(dutyId);
    }

    @Override
    public List<Map<String, String>> handleColumnMap(String[] columnArray) {
        List<Map<String, String>> columns = Lists.newArrayList();
        for (String item : columnArray) {
            Map column = LeaderDutyReportCol.getByCode(item);
            if (column != null) {
                columns.add(column);
            }
        }
        return columns;
    }
}
